﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Acms.AcmsControls;
using Acms.Bll;

public partial class Templates_TwoColumn_Default : TemplatePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void listMenu_DataBound(object sender, EventArgs e)
    {
        if (listMenu.Items.Count == 0)
        {
            LeftMenuDiv.Visible = false;
            LeftContent.Visible = true;

            LeftContent.Style[HtmlTextWriterStyle.Width] = "18%";
            LeftMenuDiv.Style[HtmlTextWriterStyle.Width] = "0%";
            fillDiv.Style[HtmlTextWriterStyle.Width] = "80%";
        }
        else
        {
            LeftMenuDiv.Visible = true;
            LeftContent.Visible = false;

            LeftMenuDiv.Style[HtmlTextWriterStyle.Width] = "18%";
            LeftContent.Style[HtmlTextWriterStyle.Width] = "0%";
            fillDiv.Style[HtmlTextWriterStyle.Width] = "80%";
        }

    }

    protected void dsMenu_SelectData(object sender, Acms.DataControls.SelectEventArgs<Acms.Bll.Post> e)
    {
        if (AcmsContext.CurrentPost != null)
        {
            //only siblings form two levels down ie ~/LevelOne/Level2
            var depth = AcmsContext.CurrentPost.Path.Split('/');
            if (depth.Count() == 3 || (depth.Count() == 4 && depth.Last() == ""))
            {
                e.SetData(Post.GetAllBySiteIdAndParentPath(AcmsContext.SiteId, AcmsContext.CurrentPost.ParentPath, AcmsContext.SiteVersion));
            }
        }
        else
        {
            e.SetData(DummyPost.CreateDummyList(4));
        }
    }

    protected Acms.AcmsControls.TemplatePage AcmsPage
    {
        get
        {
            return (Acms.AcmsControls.TemplatePage)this.Page;
        }
    }
}
